const { globalData, cloud, userStat } = getApp();

Component({
  mixins: [],
  data: {
    background: ['blue', 'red', 'yellow'],
    indicatorDots: true,
    autoplay: false,
    vertical: false,
    interval: 1000,
    circular: false,

    pageNum: 0,
    pageSize: 3,
    pageGoodDatas: [],

  },
  props: {
    testParam: '',
    goodInfoList: [],
  },
  didMount() {
    console.log("didMount goodInfoList = ")
    console.log(this.props.goodInfoList)
    this.setData({
      pageNum: Math.ceil(this.props.goodInfoList.length / this.data.pageSize),
      pageGoodDatas: [],
    })
    console.log(this.data.pageNum)

    var reList = [];
    for (var i = 0; i < this.data.pageNum; i++) {
      var pageTempList = [];
      for (var j = 0; j < this.data.pageSize; j++) {
        var index = this.data.pageSize * i + j;
        if (index < this.props.goodInfoList.length) {
          pageTempList.push(this.props.goodInfoList[index]);
        }
      }
      reList.push(pageTempList);
    }

    this.setData({
      pageGoodDatas: reList,
    })
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
    closeLayer() {
      this.$page.changeGoodInfosStatus();
    },

    printDebugInfo() {
      console.log("printDebugInfo goodInfoList = ")
      console.log(this.props.goodInfoList)

      console.log("printDebugInfo testParam = " + this.props.testParam)

      console.log("printDebugInfo goodInfoList = " + this.props.goodInfoList.length)
    },

    // onAddCartClick(e) {
    //   var goodId = e.target.dataset.value.goodId;
    //   this.$page.onAddToCart(goodId, null)
    // }

    onGoodClick(e) {
      console.log(e)
      this.$page.goGoods(e.target.targetDataset.value);
    },
  },
});
